module two {
	export function showConfirm(message: string): ConfirmBox {
		let box = new ConfirmBox("取消", "确定", message, "提 示");
		box.once("onButton1", () => {
		}, this);
		box.once("onButton2", () => {
			box.dispatchEventWith("onOK")
		}, this);
		two.showBox(box, undefined, true);
		return box;
	}

	export class ConfirmBox extends BaseComponent {
		private lb1: string;
		private lb2: string;
		private btnSkin1: string;
		private btnSkin2: string;
		protected msg: string;
		private title: string;

		public constructor(label1: string, label2: string, message: string, title: string, skinName: string = "ConfirmBox", btnSkin1: string = "", btnSkin2: string = "") {
			super(skinName);

			this.lb1 = label1;
			this.lb2 = label2;
			this.btnSkin1 = btnSkin1;
			this.btnSkin2 = btnSkin2;
			this.msg = message;
			this.title = title;
		}

		public btn1:eui.Button;
		public btn2:eui.Button;
		public txt_msg:eui.Label;

		protected created(): void {
			if (this.lb1 == null) {
				this.btn1.parent.removeChild(this.btn1);
			}
			else {
				if (this.lb1 != "") {
					this.btn1.label = this.lb1;
				}
				if (this.btnSkin1 != "") {
					this.btn1.skinName = this.btnSkin1;
				}
				this.btn1.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
					two.closeBox(this, true);
					this.dispatchEventWith("onButton1")
				}, this);
			}

			if (this.lb2 == null) {
				this.btn2.parent.removeChild(this.btn2);
			}
			else {
				if (this.lb2 != "") {
					this.btn2.label = this.lb2;
				}
				if (this.btnSkin2 != "") {
					this.btn2.skinName = this.btnSkin2;
				}
				this.btn2.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
					two.closeBox(this, true);
					this.dispatchEventWith("onButton2")
				}, this);
			}

			this.setMessage();
		}

		protected setMessage():void {
			if (this.txt_msg) {
				this.txt_msg.text = this.msg;
			}

		}

		protected added(): void {

		}

		protected removed(): void {

		}
	}
}